﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using Tank.Properties;

namespace Tank
{
    /// <summary>
    /// 闪耀登场类
    /// </summary>
    class Born : GameElement
    {
        private int bornTimer = 0;
        private static Image[] bornImg ={Resources.twinkle1,Resources.twinkle2,Resources.twinkle3,Resources.twinkle4};
        
        public Born(int x, int y)
            : base(x, y, bornImg[0].Width, bornImg[0].Height)
        {;
        }

        #region 闪耀登场

         /// <summary>
        /// 闪耀登场动画
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g)
        {
            if (bornTimer < 48)
            {
                switch (bornTimer % 8)
                {
                    case 0:
                    case 1:
                        g.DrawImage(bornImg[0], this.X, this.Y);
                        break;
                    case 2:
                    case 3:
                        g.DrawImage(bornImg[1], this.X, this.Y);
                        break;
                    case 4:
                    case 5:
                        g.DrawImage(bornImg[2], this.X, this.Y);
                        break;
                    case 6:
                    case 7:
                        g.DrawImage(bornImg[3], this.X, this.Y);
                        break;
                    default: break;
                }
                bornTimer++;
            }
        }
        #endregion
    }
}
